package cn.tedu.cake.controller;

import cn.tedu.cake.pojo.dto.CategoryDTO;
import cn.tedu.cake.service.ICategoryService;
import cn.tedu.cake.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/categorys")
@Api(tags = "01. 商品类型管理")
public class CategoryController {
    @Autowired
    private ICategoryService service;

    @PostMapping("/add-new")
    @ApiOperation("添加商品类型")
    public JsonResult addNew(CategoryDTO categoryDTO){
        service.addNew(categoryDTO);
        return JsonResult.ok();
    }

    @PostMapping("/deleteById")
    @ApiOperation("根据ID删除分类")
    public JsonResult deleteById(int id){
        service.deleteById(id);
        return JsonResult.ok();
    }


}
